<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>1 column demo</title>

  <link rel="stylesheet" href="../../../demo/demo.css"/>
  <script src="../../../dist/gridstack-all.js"></script>
  <style type="text/css">
    .grid-stack {
      width: 200px;
    }
  </style>

</head>
<body>
  <div class="container-fluid">
    <h1>1 column demo</h1>
    <div>
      <a class="btn btn-primary" onClick="addNewWidget()" href="#">Add Widget</a>
      <a class="btn btn-primary" onclick="toggleFloat()" id="float" href="#">float: true</a>
    </div>
    <br><br>
    <div class="grid-stack"></div>
  </div>
  <script src="../../../demo/events.js"></script>
  <script type="text/javascript">
    let count = 0;
    let items = [{x: 0, y: 0, w: 1, h:1, content: String(count++)}];

    let grid = GridStack.init({column: 1, minRow: 1});
    grid.load(items);
    addEvents(grid);

    addNewWidget = function() {
      let n = items[count] || {
        x: Math.round(12 * Math.random()),
        y: Math.round(5 * Math.random()),
        w: Math.round(1 + 3 * Math.random()),
        h: Math.round(1 + 3 * Math.random()),
        content: String(count++)
      };
      grid.addWidget(n);
    };

    toggleFloat = function() {
      grid.float(! grid.getFloat());
      document.querySelector('#float').innerHTML = 'float: ' + grid.getFloat();
    };
  </script>
</body>
</html>
